import 'package:flutter/material.dart';
import '../../helper/Helper.dart';
import '../../helper/cacheHelper.dart';
import '../../helper/global_config.dart';
import '../../model/report.dart';
import '../../widgets/dialogWidget.dart';
import '../../widgets/inputWidget.dart';

class ReportHelper{
  static Widget inContainer(Widget child){
     return  Container(child: child,
         color: GlobalConfig.cardBackgroundColor,
         padding: EdgeInsets.only(top:8.0,bottom: 6.0,left: 12.0),
        );
  }

  static Widget ReportCard3(
      BuildContext context, Report record, VoidCallback refrush) {

    var u1 = CacheHelper.GetUser(record.UserId);
    String _remark = Helper.DateTimeFormat(record.CreateTime);

    return Column(children:[ 
      inContainer( 
      
        Row(children:[ InputWidget.userCircle(), Text(u1.Name)])),
      InputWidget.inCard4(

          // margin: EdgeInsets.all(4.0),
          // padding: EdgeInsets.all(4.0),
           ListTile(
        onLongPress: () {
          showDialog(
            context: context,
            builder: (BuildContext context) {
              if (u1 != null && u1.Guid != record.UserId.toLowerCase()) {
                return DialogWidget.getAlert(context, "提示", "只能删除自己上传的记录");
              } else {
                return DialogWidget.getDialog(
                    context, "删除记录", "点击确定键将删除该条记录！     " + record.Content, () {
                  Report.Delete(record);
                  refrush();
                });
              }
            },
          );
        },
        title: Text(record.Content,style: TextStyle(letterSpacing: 1.6),),
      ),margin1: 0.0
      ),
       inContainer( Row(children:[ Text(
          _remark,
          style: TextStyle(color: Colors.black38, height: 1.5),
        )]),
        ),
    InputWidget.getDivider()]);
  }

}